//
//  ViewControlM.m
//  
//  jhf
//
//  Created by Mac on 2020/7/21.
//

#import "ViewControlM.h"
#import <CooperSDK/UIColor+BFPaperColors.h>
#import <CooperSDK/CALayer+Addition.h>
#import <Masonry/Masonry.h>
#import "Cooper_Table_Define.h"

@implementation ViewControlM

+ (ViewControlM *)defaultViewControl; {
    ViewControlM *control = [[ViewControlM alloc] init];
    control.vMasksToBounds = false;
    control.vLayer = false;
    control.vLayerColorHex = @"#ffffff";
    control.vRadius = 0;
    control.vHeightCons = 0.f;
    control.vWidthCons = 0.f;
    return control;
}

- (void)controlV:(UIView *)v {
    v.layer.cornerRadius = self.vRadius;
    v.layer.masksToBounds = self.vMasksToBounds;
    if (self.vLayer) {
        v.layer.borderWidth = self.vLayerWidth;
        v.layer.borderColorFromUIColor = [UIColor colorWithHexString:self.vLayerColorHex];
    }else {
        v.layer.borderWidth = 0.f;
    }
    v.backgroundColor = self.vBgColor;
    if (self.frame.size.height > 0 || self.frame.size.height > 0) {
        v.frame = self.frame;
    }
}

+ (NSArray *)mj_ignoredPropertyNames {
    return @[@"vBgColor"];
}

- (UIColor *)vBgColor {
    if (!_vBgColor) {
        if (self.vBgColorHex) {
            if ([TABLE_DEFAULT_CLEAR_COLOR_HEX isEqualToString:self.vBgColorHex]) {
                self.vBgColor = [UIColor clearColor];
            }else {
                self.vBgColor = [UIColor colorWithHexString:self.vBgColorHex];
            }
        }else {
            self.vBgColor = [UIColor clearColor];
        }
    }
    return _vBgColor;
}
@end
